package org.jsola.hr.web;

import org.jsola.core.Page;
import org.jsola.core.Result;
import org.jsola.hr.constant.HrConstants;
import org.jsola.hr.service.IHrServiceLogService;
import org.jsola.log.query.ServiceLogQuery;
import org.jsola.log.vo.ServiceLogListVO;
import org.jsola.user.core.TokenUser;
import org.jsola.user.core.UserContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;


/**
 * 服务日志
 *
 * @author june
 */
@RestController("hrHrServiceLogController")
@RequestMapping(HrConstants.API_PATH + "/v1/serviceLogs")
public class HrServiceLogController implements IHrServiceLogControllerAPI {

    @Autowired
    private IHrServiceLogService hrServiceLogService;

    @Override
    @GetMapping
    public Result<Page<ServiceLogListVO>> page(@Valid ServiceLogQuery serviceLogQuery) {
        TokenUser tokenUser = UserContext.getUser();
        // todo 查看项目权限校验

        return Result.success(
                hrServiceLogService.selectPage(serviceLogQuery, tokenUser.getSiteId())
        );
    }

    @Override
    @GetMapping("/pageNotSiteId")
    public Result<Page<ServiceLogListVO>> pageNotSiteId(@Valid ServiceLogQuery serviceLogQuery) {
        TokenUser tokenUser = UserContext.getUser();
        // todo 查看项目权限校验

        return Result.success(
                hrServiceLogService.selectPage(serviceLogQuery, null)
        );
    }


}

